<?php
include_once ("../sql_connect.php");
include_once ("../msg_redirect.php");
?>
<?php
/*Ajax调用此模块将微博写入数据库*/
$my_sql = mysql_query ( "select MAX(w_id) from weibo", $connection ); /*检查weibo表中得最大weibo编号*/
$my_result = mysql_fetch_array ( $my_sql );

/*相片数据*/
$p_data=$_COOKIE['upload_file'];


if($p_data){

/*相片编号*/
$photo_sql = mysql_query ( "select MAX(p_id) from photo", $connection ); /*检查photo表中得最大相片编号*/
$photo_result = mysql_fetch_array ( $photo_sql );
$p_id = $photo_result[0]+1;
			

/*对将要输入weibo表的数据项量进行赋值*/
$w_id = $my_result [0] + 1;
$w_content = $_POST [speach];
$u_no = $_COOKIE ['u_no'];
$w_date = time();

$my_sql1 = mysql_query ( "select MAX(w_num) from weibo where u_no='$u_no'", $connection ); /*检查weibo表中得w_num最大序号*/
$my_result1 = mysql_fetch_array ( $my_sql1 );
$w_num = $my_result1 [0] + 1;
/*插入微博数据*/
$my_sql = mysql_query ( "insert into weibo values('$w_id','$w_content','$u_no','$w_date','','','$p_id','$w_num')", $connection );


/*插入相册数据*/
mysql_query("insert into photo values('$p_id','$p_data','$u_no','$w_id')",$connection);
}
else {
/*对将要输入weibo表的数据项量进行赋值*/
$w_id = $my_result [0] + 1;
$w_content = $_POST [speach];
$u_no = $_COOKIE ['u_no'];
$w_date = time();

$my_sql1 = mysql_query ( "select MAX(w_num) from weibo where u_no='$u_no'", $connection ); /*检查weibo表中得w_num最大序号*/
$my_result1 = mysql_fetch_array ( $my_sql1 );
$w_num = $my_result1 [0] + 1;
/*插入微博数据*/
$my_sql = mysql_query ( "insert into weibo values('$w_id','$w_content','$u_no','$w_date','','','','$w_num')", $connection );
	
}

?>


